
const request = require('../../../../../utils/request');
const getTime = require('../../../../../utils/util');

Page({
    data: {
        shop: [],
        date: '2018-7-22',
        time: '19:00',
        showTime: true,
        allTime: '',
        imgUrl: request.imgUrl,
        stop:false  //店铺是否打烊
    },
    onLoad(e){
        request.HttpRequst(true,'program/shops',false,'',{"id":e.id},"GET",false,res => {
            console.log(res.data);
            let currentTime = getTime.currentTime(new Date());
            console.log(currentTime);
            this.setData({
                shop: res.data,
                date: currentTime,
                allTime: currentTime+" "+this.data.time,
                stop: res.data.shopinfo.is_open==1 ? false : true
            })
        })
        wx.showShareMenu({
            withShareTicket: true
        })
    },
    onReady: function(){
        wx.setNavigationBarTitle({
            title: '门店首页'
        })
    },
    goAdvRoom(){
        console.log(this.data.allTime)
        request.HttpRequst(true,'checkDeskRoom',2,'',{"arrive_time":this.data.allTime,"shop_id":this.data.shop.id},"GET",false,res => {
            if(res.code == 200){
                wx.navigateTo({
                    url: '../advRoom/advRoom?arrive_time='+this.data.allTime+'&shop_id='+this.data.shop.id
                })
            }else{
                wx.showModal({
                    title: '提示',
                    content: res.info,
                    showCancel: false
                })
            }
        })
        
    },
    bindDateChange: function(e) {
        this.setData({
            date: e.detail.value,
            allTime: e.detail.value+" "+this.data.time
        })
    },
    bindTimeChange: function(e) {
        this.setData({
            time: e.detail.value,
            allTime: this.data.date+" "+e.detail.value
        })
    },
    selectTime() {
        if(wx.getStorageSync('sessionId')) {
            this.setData({
                showTime: !this.data.showTime
            })
        }else {
            wx.navigateTo({
                url: '../../../../my/myLogin/myLogin'
            })
        }
        
    },

    //店铺打烊我知道了
    hiddenStop() {
        this.setData({
            stop: false
        })
    },
    //阻止默认滚动事件
    stopMove(){}
})